import { Injectable } from '@angular/core';
import { State } from '@ngxs/store';
import { PagedResultDto } from '@abp/ng.core';
import { IdentityUserDto, IdentityUserService } from '../proxy/identity';
import {
  defaultEntityListState,
  EntityListStateModel,
  EntityListStore,
} from '../../core/entity-list.state.base';

@State<EntityListStateModel<IdentityUserDto>>({
  name: 'IdentityUserList',
  defaults: defaultEntityListState(),
})
@Injectable()
export class IdentityUserListState extends EntityListStore<IdentityUserDto> {
  constructor(protected identityUserService: IdentityUserService) {
    super(IdentityUserListState);
  }
  protected onGetModels(payload: any): Promise<PagedResultDto<IdentityUserDto>> {
    return this.identityUserService.getList(payload).toPromise();
  }
  protected onDelete(payload: string): Promise<void> {
    return this.identityUserService.delete(payload).toPromise();
  }
}
